<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 单例模式
        class Singleton {
            constructor() {
                if (!Singleton.instance) {
                    this.data = "This is a singleton instance";
                    Singleton.instance = this;

                }
                return Singleton.instance;
            }
        }
        const instance1 = new Singleton();
        const instance2 = new Singleton();
        const instance3 = new Singleton();
        console.log(instance1 === instance2); // true
        // 观察者模式
        click主体 [fun1,fun2]
        div1.addEventListeners('click', function () {
            console.log(1)
        })
        div2.addEventListeners('click', function () {
            console.log(2)
        })
    </script> 
</body>
</html>